﻿@using giaoxuhaison.Models;
@using giaoxuhaison.Common;

@model ResultList

@{
    ViewBag.Title = "SearchResult";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@{
    var lstItem = Model.EntityList;    
}
<div class="LeftGroupNews">    
    <!--load tin moi -->
    @if (Model.TotalRecords > 0)
    {
        <h3 style="color:Red;">Tìm thấy @Model.TotalRecords.ToString() kết quả</h3>
        foreach (var entity in lstItem)
        {
            var strLink = "";
            var item = entity as vw_Search;
            //xu ly lay controller & action
            if (item.GroupID == 1 || item.GroupID == 2 || item.GroupID == 3 || item.GroupID == 4)
            {
                strLink = "~/News/NewsDetail?NewsID=" + item.NewsID + "&GroupID=" + item.GroupID;               
            }
            else if (item.GroupID == 5 || item.GroupID == 6 || item.GroupID == 7 || item.GroupID == 8)
            {
                strLink = "~/GodTitle/GodTitleDetail?GodTitleID=" + item.NewsID + "&GroupID=" + item.GroupID;               

            }
            else if (item.GroupID == 9 || item.GroupID == 10)
            {
                strLink = "~/Liturgies/LiturgyDetail?LiturgyID=" + item.NewsID + "&GroupID=" + item.GroupID;               
            }
            else if (item.GroupID == 11 || item.GroupID == 12)
            {
                strLink = "~/Faiths/FaithsDetail?FaithID=" + item.NewsID + "&GroupID=" + item.GroupID;               
            }
            else
            {
                strLink = "~/Culture/CultureDetail?CultureID=" + item.NewsID + "&GroupID=" + item.GroupID;               
            }            
            
            <div class="NewsGrpTitle">        
            @*<a href='@Url.Action(strAction, strController, new { CultureID = item.NewsID, GroupID = item.GroupID })'>@item.Subject</a>        *@
             <a href='@Url.Content(strLink)' >@item.Subject </a>
            </div>        
            <div class="DetailGrpNews">
                <div id="LinkGroupNews">            
                    <div class="DateGrpTitle"><i>Ngày đăng: @item.CreationDate.ToString("dd/MM/yyyy")</i></div>
                    <div class="NewsGrpContent">
                        <a href='@Url.Content(strLink)' >
                        <img id="ImgNewNews" align="left" src='@Url.Content(item.ImageContentUrl)' alt = "" style="width:200px; height:160px; max-width:200px; max-height:160px;"/>    </a>
                        <span style="padding-left:5px;">@item.ShortcutText
                        </span>
                        <a href='@Url.Content(strLink)' ><i>Đọc tiếp ...</i></a>   
                    </div>
                </div>    
            </div>
        }

        if (Model.TotalRecords > 6)
        {
            @*var groupID = (Model.EntityList.FirstOrDefault() as vw_CulturesAll).GroupID;*@
            var counter = 1;
        <div class="pagingNavigator" style="margin-bottom:10px;">
            @for (var i = 0; i < Model.TotalRecords; i += 6)
            {
                if (Model.CurrentPage == counter)
                {                
                <input type="button" value="@counter.ToString()" class="btnPager" disabled="disabled" />
                }
                else
                {
                <input type="button" value="@counter.ToString()" class="btnPager" />
                }
                counter++;
            }
        </div>
        }
    }
    else
    {
        <div class="NewsGrpTitle" style="color:Red;">        
            <strong>TÌM KIẾM</strong>
        </div>        
        <div class="DetailGrpNews">
            <div id="LinkGroupNews">
                <div class="NewsGrpContent">
                    <span style="padding-left: 5px;color:Red;">Không tìm thấy kết quả nào!</span>
                </div>
            </div>
        </div>        
    }
</div>

<div class="RightGroupNews">
    <div class="RightGroupTitle">
        @Html.Label("TIN/ BÀI MỚI", new { @class = "lblLeftTitle" })                        
    </div>
    <div class="RightGroupContent">
        <!--Hien thi phan loi Chua moi-->        
        <!--Hien thi tin tuc moi cua group-->
        @Html.Action("IndexRightNews", "News")
        @*@Html.Action("NewCulture", "Culture")*@
    </div> 
    
    <div class="RightGroupTitle">
        @Html.Label("SUY NIỆM LỜI CHÚA", new { @class = "lblLeftTitle" })                        
    </div>
    <div class="RightGroupContent">
        <!--Hien thi phan loi Chua moi-->        
        <!--Hien thi tin tuc moi cua group-->
        <!-- load phan thong bao moi -->
        <!--Hien thi phan loi Chua moi-->
        @Html.Action("NewGodTitle", "GodTitle")
    </div>      
    
</div>

<script>
    var newsAllUrl = '@Url.Action("SearchResult", "Search")';

    $(document).ready(function () {
        $('.btnPager').click(function () {

            var currenPage = $(this).attr('value');

            newsAllUrl = newsAllUrl + '?currentPage=' + currenPage;
            window.location.href = newsAllUrl;
        });
    });
</script>


